﻿{include file="public/header" /}
{css href="__ROOT__/static/public/umeditor/themes/default/css/umeditor.css" /}
{js href="__ROOT__/static/public/umeditor/third-party/template.min.js" /}
{js href="__ROOT__/static/public/umeditor/umeditor.config.js" /}
{js href="__ROOT__/static/public/umeditor/umeditor.min.js" /}
	<form method="post" class="form-x" action="{if $data.id}?id={$data.id}{/if}">
	<div class="panel admin-panel">
		<div class="panel-head"><strong>{:lang('currency')['edit']}</strong></div>
		<br/>
		<script>
            var cate_id="{$data.cate_id}";
            var uid="{$data.uid}";
            if(!uid){
                uid="{:input('get.uid')}";
			}
            function select_uid() {
                start_service_category();
            }
		</script>
		<div class="form-group">
			<div class="label">
				<label>{:lang('label')['seller']}</label>
			</div>
			<div class="field">
				{include file="public/seller" /}
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="title">{:lang('label')['category']}</label>
			</div>
			<div class="field">
				{include file="public/category" /}
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="title">{:lang('label')['title']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="title" name="title" value="{$data.title}" size="80" placeholder="{:lang('label')['title']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="price">{:lang('label')['price']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="price" name="price" value="{$data.price}" size="80" placeholder="{:lang('label')['price']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="price">{:lang('label')['box_charge']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="box_charge" name="box_charge" value="{$data.box_charge}" size="80" placeholder="{:lang('label')['box_charge']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="spec">{:lang('label')['spec']}</label>
			</div>
			<div class="field">
			{if $speclist}
			{volist name="speclist" id="spec"}
			{if $spec.title}
			<div style="padding: 5px 0px;">
				<input type="hidden" name="spec[{$i-1}][id]" size="30" value="{$spec.id}" /> 
				<input type="text" class="input input-auto" name="spec[{$i-1}][title]" size="30" value="{$spec.title}" placeholder="{:lang(\'label\')[\'spec\']}"  /> 
				<input type="text" class="input input-auto" name="spec[{$i-1}][price]" size="10" value="{$spec.price}" placeholder="{:lang(\'label\')[\'price\']}" />
				{if $i == 1}
				<button type="button" class="button addspec">+</button>
				{else}
				<button type="button" class="button delspec">-</button>
				{/if}
			</div>
			{/if}
			{/volist}
			{else}
			<div style="padding: 5px 0px;">
				<input type="hidden" name="spec[0][id]" size="30" /> 
				<input type="text" class="input input-auto" name="spec[0][title]" size="30" placeholder="{:lang(\'label\')[\'spec\']}"  /> 
				<input type="text" class="input input-auto" name="spec[0][price]" size="10" placeholder="{:lang(\'label\')[\'price\']}" />
				<button type="button" class="button addspec">+</button>
			</div>
			{/if}
			</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image1">{:lang('label')['image']}1</label>
			</div>
			<div class="field">
				<input type="text" readonly class="input input-auto" id="image1" name="image1" value="{$data.image1}" size="65" placeholder="{:lang('label')['image']}" data-validate="required:{:lang('currency')['required']}" />
				<span class="addbtn"><button type="button" data-id="image1" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image2">{:lang('label')['image']}2</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image2" name="image2" value="{$data.image2}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image2" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image3">{:lang('label')['image']}3</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image3" name="image3" value="{$data.image3}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image3" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image4">{:lang('label')['image']}4</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image4" name="image4" value="{$data.image4}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image4" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<!--<div class="form-group">
			<div class="label">
				<label>商品类型</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if $data.type == "0" || !$data.type}active{/if}"><input name="type" value="0" {if $data.type == "0" || !$data.type}checked="checked"{/if} type="radio">商品外卖</label>
					<label class="button {if $data.type == "1"}active{/if}"><input name="type" value="1" {if $data.type == "1"}checked="checked"{/if} type="radio">上门服务</label>
					<label class="button {if $data.type == "2"}active{/if}"><input name="type" value="2" {if $data.type == "2"}checked="checked"{/if} type="radio">到店使用</label>
				</div>
			</div>
		</div>-->
		<div class="form-group">
			<div class="label">
				<label>{:lang('label')['status']}</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if !$data.status}active{/if}"><input name="status" value="0" {if !$data.status}checked="checked"{/if} type="radio"> <span class="icon icon-times"></span>下架</label>
					<label class="button {if $data.status == "1"}active{/if}"><input name="status" value="1" {if $data.status == "1"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 上架</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>必选</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if $data.required == "1"}active{/if}"><input name="required" value="1" {if $data.required == "1"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 是</label>
					<label class="button {if !$data.required}active{/if}"><input name="required" value="0" {if !$data.required}checked="checked"{/if} type="radio"> <span class="icon icon-times"></span> 否</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>是否店内</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if $data.type == "1"}active{/if}"><input name="type" value="1" {if $data.type == "1"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 是</label>
					<label class="button {if !$data.type}active{/if}"><input name="type" value="0" {if !$data.type}checked="checked"{/if} type="radio"> <span class="icon icon-times"></span> 否</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>活动</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if !$data.flag}active{/if}"><input name="flag" value="0" {if !$data.flag}checked="checked"{/if} type="radio"> <span class="icon icon-check"></span> 无</label>
					<label class="button {if $data.flag == "1"}active{/if}"><input name="flag" value="1" {if $data.flag == "1"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 团购</label>
					<label class="button {if $data.flag == "2"}active{/if}"><input name="flag" value="2" {if $data.flag == "2"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 秒杀</label>
					<label class="button {if $data.flag == "3"}active{/if}"><input name="flag" value="3" {if $data.flag == "3"}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> 限时购</label>
				</div>
			</div>
		</div>
		{css href="__ROOT__/static/admin/css/daterangepicker.css" /}
		{js href="__ROOT__/static/public/js/moment.js" /}
		{js href="__ROOT__/static/public/js/daterangepicker.js" /}
		<style>
			.daterangepicker{
				display:none;
				border: 1px solid #08C;
			}
		</style>
		<div class="form-group">
			<div class="label">
				<label>时间</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
						<button type="button" class="button button-default pull-right" id="daterange-btn">
							<span>
							{if $data['start_time']}
							{$data['start_time']|date='Y-m-d H:i',###} 至 {$data['end_time']|date='Y-m-d H:i',###}
							{else}
							  <i class="icon-calendar"></i> 日期选择
							{/if}
							</span>
							<i class="icon-caret-down"></i>
						</button>
						<input type="hidden" id="start_time" name="start_time" value="{$data.start_time}"/>
						<input type="hidden" id="end_time" name="end_time" value="{$data.end_time}"/>
						<script>
							var start_time="{$data.start_time}",end_time="{$data.end_time}";
							$('#daterange-btn').daterangepicker({
									opens: "right",
									drops:"up",
									ranges: {
										'今天': [moment(), moment()],
										'本周': [moment().startOf('week'), moment().endOf('week')],
										'本月': [moment().startOf('month'), moment().endOf('month')],
										'今年': [moment().startOf('year'), moment().endOf('year')]
									},
									timePicker:true,
									startDate: moment(),
									endDate: moment().endOf('month')
								},
								function(start, end) {
									start_time = start.format('YYYY-M-DD h:mm A');
									end_time = end.format('YYYY-M-DD h:mm A');
									$('#daterange-btn span').html(start_time + ' 至 ' + end_time);
									$('#start_time').val(start_time);
									$('#end_time').val(end_time);
								}
							);
						</script>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>打</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<input type="number" min="0.0" step="0.1" value="{$data.discount}" name="discount" max="10" class="input input-auto" style="width: 80px"> 折
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>介绍</label>
			</div>
			<div class="field">
				<textarea name="service" class="input input-auto" rows="5" cols="80" style="min-height: 165px" placeholder="商品介绍">{$data.service}</textarea>
			</div>
		</div>
		<div id="refuse" class="form-group{if $data.status != '4'} hidden {/if}">
			<div class="label">
				<label for="refuse">{:lang('label')['refuse']}</label>
			</div>
			<div class="field">
				<textarea name="refuse" class="input input-auto" rows="5" cols="80" placeholder="{:lang('label')['refuse']}" >{$data.refuse}</textarea>
			</div>
		</div>
		<div class="form-button">
			<button class="button bg-main" type="submit">{:lang('form')['submit']}</button>
		</div>
		<br/>
		</div>
	</form>
		<script>
		$("[name='status']").click(function(){
			var status = $("[name='status']:checked").val();
			if(status=='4'){
				$("#refuse").removeClass('hidden');
			}else{
				$("#refuse").addClass('hidden');
			}
		});
		$(".addspec").click(function(){
			var num = $(this).parent().parent().find("div").length;
			var html = '<div style="padding: 5px 0px;"><input type="text" class="input input-auto" name="spec['+num+'][title]" size="30" placeholder="{:lang(\'label\')[\'spec\']}"  /> <input type="text" class="input input-auto" name="spec['+num+'][price]" size="10" placeholder="{:lang(\'label\')[\'price\']}" /> <button type="button" class="button delspec">-</button></div>';
			$(this).parent().parent().append(html);
		});
		$(document).on("click",".delspec",function(){
			$(this).parent().remove();
		})
		var um = UM.getEditor('myEditor');
	</script>
{include file="public/footer" /}